package com.cpimex.eprice.usuarios;

import java.util.*;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

public class Director extends Usuario{
    public Director() {
    }

    public ArrayList listado(Connection conn, String str_query2, Map map_where, int int_ordenar,
                             boolean bol_orderAsc) throws Exception {
        String str_query = super.str_query;
        ArrayList arr_result = null;
        
        Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
        ResultSet rs = stmt.executeQuery("SELECT autorizaExportacion FROM ep_claseProducto WHERE codigo_dir="+super.getStr_nomina());
        if(rs.getInt("autorizaExportacion")==1){
        	str_query += " OR  vendedor_cli like 'EX%') ";
        }else{
        	str_query += " AND vendedor_cli not like 'EX%') ";
        }
        
        str_query += " where ( estatus_sol in ('NVA', 'PENGTE', 'RCHZ-GTE', 'PENDIR', 'RCHZ-DIR', 'PENVPO') or ( estatus_sol = 'AUTORIZADA' and precio_sol >= precioActual_sol and precio_sol >= precioLista_sol ) ) ";

        String str_ejecutivo = map_where.get("str_ejecutivo")==null || map_where.get("str_ejecutivo").equals("") ?"":((String) map_where.get("str_ejecutivo"));
        String str_coord     = map_where.get("str_coord")==null || map_where.get("str_coord").equals("") ?"":((String) map_where.get("str_coord"));
        String str_gerente   = map_where.get("str_gerente")==null || map_where.get("str_gerente").equals("") ?"":((String) map_where.get("str_gerente"));

        str_query +=
                (str_ejecutivo.equals("")?"":" AND " + " codigoVen_sol = '" + str_ejecutivo + "' ") +
                (str_coord.equals("")    ?"":" AND " + " coordinadoraCli_sol = '" + str_coord + "' ") +
                (str_gerente.equals("")  ?"":" AND " + " claseProducto_sol = '" + str_gerente + "' ");

        arr_result = super.listado(conn, str_query, map_where, int_ordenar, bol_orderAsc);

        return arr_result;
    }
}
